#ifndef __UTILS__LOAD_ELEMENT__
#define __UTILS__LOAD_ELEMENT__

#include "../include/Element.hpp"
#include <fstream>
#include <iostream>

std::vector<Element> load_element(std::vector<Point>& points)
{
    std::vector<Element> elements;
    std::ifstream fin("../data/domain.e");
    unsigned long num_element;
    fin >> num_element;
    std::cerr << "domain.e has " << num_element << " elements in total." << std::endl;
    char en[100];
    unsigned long i, j, k;
    long ei, ej, ek;
    unsigned long si, sj, sk;
    double xV, yV;
    int marker;
    for(unsigned long idx=0; idx<num_element; idx++)
    {
        fin >> en \
            >> i >> j >> k \
            >> ei >> ej >> ek \
            >> si >> sj >> sk \
            >> xV >> yV \
            >> marker;
        bool bound = 0;

        if(is_boundary(points[i]) or is_boundary(points[j]) or is_boundary(points[k]))
        {
            bound = 1;
        }
        Element e(idx, {points[i],points[j],points[k]}, bound);
        elements.push_back(e);
/***
        if(idx%50 == 0)
        {
            std::cerr << "reading Element" << idx << std::endl;
            std::cout << e;
        }
***/
    }
    fin.close();
    std::cerr << "finish reading data from domain.e" << std::endl;
    return elements;
}
#endif
